home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Sample Code / Sample Editors⁄Viewers / Sound Editor / Source / SoundEditor.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-11  |  10.5 KB  |  349 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        SoundEditor.h
  3.  
  4.     Contains:    Sound Editor class implementation
  5.  
  6.     Written by:    Steve Smith, Andrey Dolgachev, and Troy Gaul
  7.     
  8.     Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  9. */
  10.  
  11. #ifndef _SOUNDEDITOR_
  12. #define _SOUNDEDITOR_
  13.  
  14. // -- Compiler/Preprocessor Switches --
  15.  
  16. #ifndef _COMPILERDEFS_
  17. #include "CompDefs.h"
  18. #endif
  19.  
  20. // -- Forward Declarations --
  21.  
  22. struct Environment;
  23. class ODExtension;
  24. class ODFacet;
  25. class ODFocusSet;
  26. class ODFrame;
  27. class ODMenuBar;
  28. class ODPart;
  29. class ODShape;
  30. class ODStorageUnit;
  31. class ODStorageUnitView;
  32. class ODTypeList;
  33. class ODWindow;
  34. class CList;
  35. class CPlayer;
  36. class CRecorder;
  37. class CSounder;
  38. class som_SESettingsExtension;
  39. class SoundEditorSI;
  40. struct WindowProperties;
  41.  
  42. #pragma import on
  43.  
  44. //============================================================================
  45. // Constants
  46. //============================================================================
  47.  
  48. // EButton enum:
  49. enum {
  50.     kNoButton = -1,
  51.     kRecordButton,
  52.     kStopButton,
  53.     kPauseButton,
  54.     kPlayButton
  55. };
  56.  
  57. // EButtonState enum:
  58. enum {
  59.     kButtonStateNormal,
  60.     kButtonStatePressed,
  61.     kButtonStateOn,
  62.     kButtonStateDim
  63. };
  64.  
  65. //============================================================================
  66. // SoundEditor class
  67. //============================================================================
  68.  
  69. class SoundEditor {
  70.     
  71.       //==================================
  72.       // Overridden Public ODPart Methods
  73.       //==================================
  74.     public:
  75.     
  76.     SoundEditor();
  77.     ~SoundEditor();
  78.     
  79.     // -- Initialization --
  80.     
  81.     void        InitPart(Environment* ev, ODStorageUnit* storageUnit,
  82.                                         ODPart* partWrapper);
  83.     void        InitPartFromStorage(Environment* ev, ODStorageUnit* storageUnit,
  84.                                         ODPart* partWrapper);
  85.     
  86.     // -- Storage --
  87.     
  88.     void        Release(Environment* ev);
  89.     void        ReleaseAll(Environment* ev);
  90.     ODSize        Purge(Environment* ev, ODSize size);
  91.     void        Externalize(Environment* ev);
  92.     void        ExternalizeKinds(Environment* ev, ODTypeList* kindset);
  93.     void        ChangeKind(Environment* ev, ODType kind);
  94.     void        CloneInto(Environment* ev, ODDraftKey key,
  95.                                         ODStorageUnit* destinationSU,
  96.                                         ODFrame* initiatingFrame);
  97.     void        WritePartInfo(Environment* ev, ODInfoType partInfo,
  98.                                         ODStorageUnitView* storageUnitView);
  99.     ODInfoType    ReadPartInfo(Environment* ev, ODFrame* frame,
  100.                                         ODStorageUnitView* storageUnitView);
  101.     void        ClonePartInfo(Environment *ev, ODDraftKey key, ODInfoType partInfo,
  102.                                         ODStorageUnitView* storageUnitView,
  103.                                         ODFrame* scopeFrame);
  104.     
  105.     // -- Layout --
  106.     
  107.     void        DisplayFrameAdded(Environment* ev, ODFrame* frame);
  108.     void        DisplayFrameRemoved(Environment* ev, ODFrame* frame);
  109.     void        DisplayFrameClosed(Environment* ev, ODFrame* frame);
  110.     void        DisplayFrameConnected(Environment* ev, ODFrame* frame);
  111.     void        AttachSourceFrame(Environment* ev, ODFrame* frame,
  112.                                         ODFrame* sourceFrame);
  113.     void        ViewTypeChanged(Environment* ev, ODFrame* frame);
  114.     void        FrameShapeChanged(Environment* ev, ODFrame* frame);
  115.     ODID        Open(Environment* ev, ODFrame* frame);
  116.         
  117.     // -- Imaging --
  118.     
  119.     void        Draw(Environment* ev, ODFacet* facet, ODShape* invalidShape);
  120.     void        GeometryChanged(Environment* ev, ODFacet* facet,
  121.                                         ODBoolean clipShapeChanged,
  122.                                         ODBoolean externalTransformChanged);
  123.     void        HighlightChanged(Environment* ev, ODFacet* facet);
  124.     void        FacetAdded(Environment* ev, ODFacet* facet);
  125.     void        FacetRemoved(Environment* ev, ODFacet* facet);
  126.     
  127.     // -- Activation --
  128.     
  129.     ODBoolean    BeginRelinquishFocus(Environment* ev, ODTypeToken focus,
  130.                                         ODFrame* ownerFrame,
  131.                                         ODFrame* proposedFrame);
  132.     void        CommitRelinquishFocus(Environment* ev, ODTypeToken focus,
  133.                                         ODFrame* ownerFrame,
  134.                                         ODFrame* proposedFrame);
  135.     void        AbortRelinquishFocus(Environment* ev, ODTypeToken focus,
  136.                                         ODFrame* ownerFrame,
  137.                                         ODFrame* proposedFrame);
  138.     void        FocusAcquired(Environment* ev, ODTypeToken focus,
  139.                                         ODFrame* ownerFrame);
  140.     void        FocusLost(Environment* ev, ODTypeToken focus,
  141.                                         ODFrame* ownerFrame);
  142.     void        RelinquishAllFoci(Environment* ev, ODFrame* frame);
  143.     
  144.     // -- Event Handling --
  145.     
  146.     ODBoolean    HandleEvent(Environment* ev, ODEventData* event,
  147.                                         ODFrame* frame, ODFacet* facet,
  148.                                         ODEventInfo* eventInfo);
  149.     void        AdjustMenus(Environment* ev, ODFrame* frame);
  150.  
  151.     ODBoolean    HandleSoundEvent(Environment* ev, ODCommandID command);
  152.     
  153.     // -- Extension --
  154.     
  155.     ODBoolean        HasExtension(Environment *ev, ODType extensionName);
  156.     ODExtension*    AcquireExtension(Environment *ev, ODType extensionName);
  157.     ODBoolean        ReleaseExtension(Environment *ev, ODExtension* extension);
  158.     
  159.       //===================================
  160.     // Newly Introduced Internal Methods
  161.       //===================================
  162.  
  163.     // -- Settings Dialog (these methods must be public) --
  164.     
  165.     void        ShowSettingsDialog(Environment* ev, ODFrame* frame);
  166.  
  167.     // -- Sound Data Handling --
  168.  
  169.     ODBoolean    SoundPlaying();
  170.     ODBoolean    SoundRecording();
  171.     ODBoolean    SoundPaused();
  172.  
  173.     OSType        GetRecordingQuality();
  174.     void        SetRecordingQuality(OSType rQuality);
  175.     ODBoolean    GetSoundQuality(OSType* rQuality);
  176.     
  177.     ODULong        GetCurrentTime();
  178.     ODULong        GetMaxTime();
  179.     ODULong        GetRecordedTime();
  180.     
  181.       //========================
  182.     protected:
  183.     
  184.     // -- Initialization --
  185.     
  186.     void        Initialize(Environment* ev);
  187.     void        BuildMenuBar(Environment* ev);
  188.     
  189.     // -- Storage --
  190.     
  191.     void        CheckAndAddProperties(Environment* ev,
  192.                                         ODStorageUnit* storageUnit);
  193.     void        CleanseContentProperty(Environment* ev,
  194.                                         ODStorageUnit* storageUnit);
  195.     void        InternalizeStateInfo(Environment* ev,
  196.                                         ODStorageUnit* storageUnit);
  197.     void        InternalizeAnnotation(Environment* ev,
  198.                                         ODStorageUnit* storageUnit);
  199.     void        InternalizeContent(Environment* ev,
  200.                                         ODStorageUnit* storageUnit);
  201.     void        ExternalizeStateInfo(Environment* ev,
  202.                                         ODStorageUnit* storageUnit,
  203.                                         ODDraftKey key, ODFrame* scopeFrame);
  204.     void        ExternalizeAnnotation(Environment* ev, 
  205.                                         ODStorageUnit* storageUnit,
  206.                                         ODDraftKey key, ODFrame* scopeFrame);
  207.     void        ExternalizeContent(Environment* ev, ODStorageUnit* storageUnit,
  208.                                         ODDraftKey key, ODFrame* scopeFrame,
  209.                                         ODTypeToken kindToken);
  210.     void        SetDirty(Environment* ev);
  211.     
  212.     // -- Event Handling --
  213.     
  214.     ODBoolean    HandleMenuEvent(Environment* ev, ODEventData* event,
  215.                                         ODFrame* frame);
  216.     ODBoolean    HandleMouseEvent(Environment* ev, ODEventData* event,
  217.                                         ODFacet* facet, ODEventInfo* eventInfo);
  218.     ODBoolean     HandleKeyboardEvent(Environment* ev, ODEventData* event,
  219.                                         ODFrame* frame);
  220.     ODBoolean    DoMouseUp(Environment* ev, ODEventData* event, ODFacet* facet,
  221.                                         ODEventInfo* eventInfo);
  222.     void        DoMouseDown(Environment* ev, ODEventData* event, ODFacet* facet,
  223.                                         ODEventInfo* eventInfo);
  224.     
  225.     // -- Imaging --
  226.     
  227.     void        DrawFrameView(Environment* ev, ODFacet* facet);
  228.     void        DrawIconView(Environment* ev, ODFacet* facet);
  229.     void        DrawThumbnailView(Environment* ev, ODFacet* facet);
  230.     PicHandle    GenerateThumbnail(Environment* ev, ODFrame* frame);
  231.     
  232.     // -- Activation --
  233.     
  234.     void        PartActivated(Environment* ev, ODFrame* frame);
  235.     ODBoolean    ActivateFrame(Environment* ev, ODFrame* frame);
  236.     void        WindowActivating(Environment* ev, ODFrame* frame,
  237.                                         ODBoolean activating);
  238.     
  239.     // -- Layout --
  240.     
  241.     ODWindow*    AcquireFramesWindow(Environment* ev, ODFrame* frame);
  242.     ODWindow*    CreateWindow(Environment* ev, ODFrame* frame, 
  243.                                         ODType frameType,
  244.                                         WindowProperties* windowProperties);
  245.     void         CleanupWindow(Environment* ev, ODFrame* frame);
  246.     WindowProperties*    GetDefaultWindowProperties(Environment* ev, 
  247.                                         ODFrame* frame, Rect* windowRect);
  248.     WindowProperties*    GetSavedWindowProperties(Environment* ev, 
  249.                                         ODFrame* frame);
  250.     Rect        CalcPartWindowSize(Environment* ev, ODFrame* sourceFrame);
  251.     Rect        CalcPartWindowPosition(Environment* ev, ODFrame* frame,
  252.                                         Rect* partWindowBounds);
  253.     void        ZoomPartWindow(Environment* ev, ODFrame* frame, ODWindow* window,
  254.                                            ODBoolean openingWindow);
  255.     ODFacet*    GetActiveFacetForFrame(Environment* ev, ODFrame* frame);
  256.     ODShape*    CalcNewUsedShape(Environment* ev, ODFrame* frame);
  257.     void        UpdateFrame(Environment* ev, ODFrame* frame, ODTypeToken view,
  258.                                         ODShape* usedShape);
  259.     void        CleanupDisplayFrame(Environment* ev, ODFrame* frame,
  260.                                         ODBoolean frameRemoved);
  261.     
  262.     // -- Sound Data Handling --
  263.     
  264.     void        PlaySound(Environment* ev);
  265.     void        StopPlayingSound(Environment* ev);
  266.     void        PausePlayingSound(Environment* ev);
  267.     void        ResumePlayingSound(Environment* ev);
  268.     ODBoolean    SoundDonePlaying(Environment* ev);
  269.     
  270.     void        RecordSound(Environment* ev);
  271.     void        StopRecordingSound(Environment* ev);
  272.     void        PauseRecordingSound(Environment* ev);
  273.     void        ResumeRecordingSound(Environment* ev);    
  274.     ODBoolean    SoundDoneRecording(Environment* ev);
  275.     
  276.     void        DrawMaxTime(Environment* ev, ODFacet* facet);
  277.     void        DrawCurrentTime(Environment* ev, ODFacet* facet,
  278.                                         ODSShort oldTime, ODSShort curTime);
  279.     void        DrawProgressBar(Environment* ev, ODFacet* facet,
  280.                                         ODSShort progress, ODSShort pixPatID);
  281.     ODBoolean    UpdateDisplay(Environment* ev, CSounder* sounder);
  282.     
  283.     void        CopySound(Environment* ev, ODFrame* frame);
  284.     void        AnnotateClipboard(Environment* ev, ODFrame* frame);
  285.     void        PasteSound(Environment* ev, ODFrame* frame);
  286.     void        ClearSound(Environment* ev, ODFrame* frame);
  287.     ODBoolean    SoundOnClipboard(Environment* ev, ODFrame* frame);
  288.     
  289.     // -- Utilities
  290.     
  291.     PicHandle    LoadControls(Environment* ev, ODFrame* frame);
  292.     void        DoDialogBox(Environment* ev, ODFrame* frame, 
  293.                                         ODSShort dialogID,
  294.                                         ODUShort errorNumber = 0);
  295.     ODFrame*    FindFirstAvailableFrame(Environment* ev);
  296.     void        InvalidateFrameViewRect(Environment* ev, Rect& bounds);
  297.                                             
  298.     // -- Button Handling
  299.  
  300.     typedef ODSShort EButton;
  301.     typedef ODSShort EButtonState;
  302.     
  303.     void        DrawButton(Environment*    ev, EButton, EButtonState);
  304.     ODBoolean    TrackButton(Environment* ev, EButton button, Point where,
  305.                             EButtonState initialState = kButtonStateNormal);
  306.     void        InvalidateButton(Environment* ev, EButton button);
  307.  
  308.     // -- More sound utilities
  309.     
  310.     ODBoolean    IsPlayAvailable();
  311.     ODBoolean    IsPauseAvailable();
  312.     ODBoolean    IsStopAvailable();
  313.     ODBoolean    IsRecordAvailable();
  314.  
  315.       //========================
  316.     private:
  317.  
  318.     ODPart*                        fSelf;
  319.     ODSession*                    fSession;
  320.  
  321.     CList*                        fDisplayFrames;
  322.     SoundEditorSI*                fSemIntf;
  323.     som_SESettingsExtension*    fSettingsExtension;
  324.     
  325.     Handle                        fControls;
  326.     
  327.     CPlayer*                    fPlayer;
  328.     CRecorder*                    fRecorder;
  329.  
  330.     ODTypeToken                    fPreferredKind;
  331.  
  332.     ODULong                        fMenuSavedResFile;
  333.  
  334.     OSType                        fRecordingQuality;
  335.     ODULong                        fCurrentTime;
  336.     
  337.     ODULong                        fSecsRecorded;
  338.     ODSLong                        fMaxMemory;
  339.     ODSLong                        fMaxSeconds;
  340.     
  341.     ODBoolean                    fUnknownSound;
  342.  
  343.     ODBoolean                    fDirty;
  344.     ODBoolean                    fReadOnlyStorage;
  345. };
  346.  
  347. #pragma import off
  348.  
  349. #endif